package com.hzj.config;

import lombok.Data;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Configuration;
import
        org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration;

@Configuration
@Data
public class ElasticsearchConfig extends AbstractElasticsearchConfiguration {

    //重写父类方法
    @Override
    public RestHighLevelClient elasticsearchClient() {
        RestClientBuilder builder = RestClient.builder(new HttpHost("127.0.0.1", 1001)/*多个地址创建多个HttpHost对象就行*/);
        RestHighLevelClient restHighLevelClient = new
                RestHighLevelClient(builder);
        return restHighLevelClient;
    }
}